package com.hmall.search.controller;


import com.hmall.common.dto.PageDTO;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class ItemController {
    @Autowired
    private SearchService itemService;

    @GetMapping("suggestion")
    public List<String> getSuggestion(@RequestParam("key") String key) {
        return itemService.getSuggestion(key);
    }

    @PostMapping("filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestParams params) {
        return itemService.getFilters(params);
    }

    @PostMapping("list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params) {
        return itemService.search(params);
    }



}
